import http from '../../utils/http'

/**
 * @description 个性化饮食推荐接口
 * @param {Object} healthData - 用户健康数据
 * @param {number} healthData.bmi - BMI指数
 * @param {string} healthData.bmiStatus - BMI状态
 * @param {number} healthData.bodyFatRate - 体脂率
 * @param {Object} healthData.bloodPressure - 血压数据
 * @param {number} healthData.bloodPressure.systolic - 收缩压
 * @param {number} healthData.bloodPressure.diastolic - 舒张压
 * @param {Object} healthData.bloodSugar - 血糖数据
 * @param {number} healthData.bloodSugar.fasting - 空腹血糖
 * @param {number} healthData.bloodSugar.postprandial - 餐后血糖
 * @param {string} mealType - 餐次类型 (breakfast/lunch/dinner/snack)
 * @param {number} limit - 推荐数量限制
 * @returns {Promise} 推荐结果
 */
export const reqPersonalizedRecommendation = (healthData, mealType = 'all', limit = 10) => {
  const requestData = {
    healthData,
    mealType,
    limit
  };
  
  console.log('发送个性化推荐请求:', requestData);
  return http.post('/health/personalized-recommendation', requestData);
}

/**
 * @description 基于健康风险的食谱筛选接口
 * @param {Object} healthRisks - 健康风险数据
 * @param {string} healthRisks.bmiRisk - BMI风险
 * @param {string} healthRisks.bodyFatRisk - 体脂率风险
 * @param {string} healthRisks.bloodPressureRisk - 血压风险
 * @param {string} healthRisks.bloodSugarRisk - 血糖风险
 * @returns {Promise} 筛选结果
 */
export const reqHealthRiskFilter = (healthRisks) => {
  return http.post('/health/risk-filter', healthRisks);
}

/**
 * @description 获取营养建议接口
 * @param {Object} healthMetrics - 健康指标
 * @returns {Promise} 营养建议
 */
export const reqNutritionAdvice = (healthMetrics) => {
  return http.post('/health/nutrition-advice', healthMetrics);
}

/**
 * @description 获取饮食禁忌接口
 * @param {Object} userProfile - 用户档案
 * @param {string} userProfile.allergy - 过敏信息
 * @param {string} userProfile.special - 特殊疾病
 * @param {string} userProfile.medicine - 用药情况
 * @returns {Promise} 饮食禁忌
 */
export const reqDietaryRestrictions = (userProfile) => {
  return http.post('/health/dietary-restrictions', userProfile);
}
